git submodule

为什么需要 git submodule 子模块 git文档

当某个项目需要包含并使用另外一个项目,也许是第三方库,或者你独立开发的模块,用于多个父项目的库。现在问题来了:你想要把它们当做两个独立的项目,同时又想在一个项目中使用另一个。

git submodule 子模块就可以实现这样的项目需要。

开始使用

父项目: http://github.com/user/project.git

子项目1 module1: http://github.com/user/module1.git

#添加子模块到父项目
       # clone 父项目
       git clone  http://github.com/user/project.git
       # 添加 子模块
       cd project
       git submodule add http://github.com/user/module1.git module1
       git status
#在父模块中更新子模块
       # 只更新 module1 子模块
       git submodule update --remote module1
       # 更新全部的 module 模块
       git submodule update --remote
#下载所有子模块
       git clone --recurse-submodules http://github.com/user/project.git
# git 

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×